package de.hsma.srn.view.components;

import java.awt.Image;
import java.io.File;

import javax.swing.ImageIcon;

public class KeysListItem {

	private static final String DEFAULT_ICON_PATH = "Images/keys.png";

	private ImageIcon mIcon;

	private String mText;

	private String mPath;

	public KeysListItem(String iconpath, String path) {
		mIcon = new ImageIcon(iconpath);
		Image img = mIcon.getImage().getScaledInstance(24, 24,
				Image.SCALE_SMOOTH);
		mIcon = new ImageIcon(img);
		mPath = path;
		mText = parsePath(path);
	}

	public KeysListItem(String text) {
		this(DEFAULT_ICON_PATH, text);
	}

	public ImageIcon getIcon() {
		return mIcon;
	}

	public String getPath() {
		return mPath;
	}

	public String getText() {
		return mText;
	}

	@Override
	public String toString() {

		return mText;
	}

	private String parsePath(String text) {

		File f = new File(text);
		text = f.getName();

		return text;
	}

}
